﻿using System;
using FBGraph.Models;

namespace FBGraph.Controllers
{
    public partial class PostsController : IFBGraphPrimaryController<Post>, IFBGraphSearchController<Post>
    {
        /// <summary>Adds a <see cref="Like" /> to the currently authenticated user for the Graph API object identified by <paramref name="id" />.</summary>
        /// <param name="id">The Graph API identifier of the object to like.</param>
        /// <returns><c>true</c> if a like was successfully added; otherwise, <c>false</c>.</returns>
        public Boolean Like(Object id)
        {
            var result = Context.Post(id, "likes", null);
            return Boolean.Parse(result);
        }

        /// <summary>Removes a <see cref="Like" /> for the currently authenticated user for the Graph API object identified by <paramref name="id" />.</summary>
        /// <param name="id">The Graph API identifier of the object to unlike.</param>
        /// <returns><c>true</c> if a like was successfully added; otherwise, <c>false</c>.</returns>
        public Boolean Unlike(Object id)
        {   
            var result = Context.Delete(id, "likes");
            return Boolean.Parse(result);
        }

        #region [ IFBGraphSearchController<Post> Members ]

        String IFBGraphSearchController<Post>.SearchType
        {
            get { return "post"; }
        }

        #endregion
    }
}